<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.auth.*" pageEncoding="utf-8"%>
<%
HsAccount accInfo = (HsAccount)request.getSession().getAttribute(AUTHConstant.USERINSESSION);
HsUserinfo userinfo = accInfo==null?null:accInfo.getUserinfo();
String accid = String.valueOf(accInfo==null?"":accInfo.getId());
String treeStr1 = (String)request.getAttribute("treeStr1"); 
String treeStr2 = (String)request.getAttribute("treeStr2");  
String treeStr3 = (String)request.getAttribute("treeStr3"); 
String treeStr4 = (String)request.getAttribute("treeStr4"); 

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head> 
<%@ include file="../../include.jsp"%> 
<script src='<%=basePath%>thirtpart/jquery/jquery.blockUI.js'></script> 
<script src='<%=basePath%>app/js/hs.search.js'></script> 
<link rel="stylesheet" type="text/css" href="<%=basePath %>thirtpart/dhtmlx25/dhtmlxlayout.css"/>
<link rel="STYLESHEET" type="text/css" href="<%=basePath %>thirtpart/dhtmlx25/dhtmlxtree.css"/>
<link rel="stylesheet" type="text/css" href="<%=basePath %>thirtpart/dhtmlx25/skins/dhtmlxlayout_dhx_blue.css"/>
<script src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcommon.js"></script>
<script src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxlayout.js"></script> 
<script src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcontainer.js"></script>  
<script  src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxtree.js"></script>   
<style>.tac{text-align:center}</style>
<script language=JavaScript> 
function datastat(){
	//var win = document.getElementById('resultlist').contentWindow;
	//var allsql = win.document.getElementById('allfullsql').value;
    //openwindow('<%=basePath%>stat/statindex.do?allsql='+encodeURI(allsql),'1280','960','');
	basiclinchuang('','','<%=basePath %>');
}
function datastatadv(){
	//var win = document.getElementById('resultlist').contentWindow;
	//var allsql = win.document.getElementById('allfullsql').value;
    //openwindow('<%=basePath%>stat/statindex.do?allsql='+encodeURI(allsql),'1280','960','');
	advlinchuang('','<%=basePath %>');
}
function queryinfo(id){
	
}
</script>
</head>
<body>
<dl class="treeWrapcata">
     
    <dd>
       	<div id="treeboxbox_tree" style="width:95%;margin-left:10px;overflow:auto;border:0px solid #bdc0c3;"></div>   
    </dd>
</dl>
<div class="contcata">
<table border="0" cellpadding="0" cellspacing="0" class="sear_tab">
    <tr>
      <td align="center" colspan="2" style="padding:0; text-align:center">
      	 <font size="4"><Strong>病名分类信息维护</Strong></font>
      </td>
    </tr>
     
</table>
<div class="listWrap">
<table border="0" cellpadding="0" cellspacing="0" class="tableList">
<tr>
      <td width="20%" style="padding:0; text-align:center"> 
                 病名
      </td>
      <td style="padding:0;" align="left">
      	 <span id="disid"> <input name="" type="text" style="width:98%"/></span>
      </td>
    </tr>
    <tr>
      <td width="20%" style="padding:0; text-align:center"> 
                 英文病名
      </td>
      <td style="padding:0;" align="left">
      	 <span id="disid"> <input name="" type="text" style="width:98%"/></span>
      </td>
    </tr>
    <tr>
      <td width="20%" style="padding:0; text-align:center"> 
                 中医病名
      </td>
      <td style="padding:0;" align="left">
      	 <span id="disid"> <input name="" type="text" style="width:98%"/></span>
      </td>
    </tr>
    <tr>
      <td width="20%" style="padding:0; text-align:center"> 
                 异名
      </td>
      <td style="padding:0;" align="left">
      	 <span id="disid"> <input name="" type="text" style="width:98%"/></span>
      </td>
    </tr>
    <tr>
      <td width="20%" style="padding:0; text-align:center"> 
                 排序号
      </td>
      <td style="padding:0;" align="left">
      	 <span id="disid"> <input name="" type="text" style="width:98%"/></span>
      </td>
    </tr>
     <tr>
      <td colspan="2" style="padding:0; text-align:center"> 
          <input  type="button" class="btn btn-primary" value="保存" />&nbsp;&nbsp;
          <input  type="button" class="btn btn-primary" value="新增下级病名" />
      </td>
    </tr>
</table>
</div>

</div>
</body>
</html>
<script> 
var tagtype = "";
//获得所有被选中的选项
function getAllselectedId() {  
    var selectedList = tree.getAllChecked();  
    return selectedList;
    
}
//清除所有被选中的选项
function clearAllSelectedItem(){
     if(tagtype != "")
	   tree.refreshItem(tagtype);
    //tree.clearSelection();
}
function submitSearch(){ 
   window.parent.searchresult.submitSearchForm();
}
function tonclick(itemId) {
    if(itemId == 10000 || itemId==1 || itemId == 2 || itemId == 3 || itemId ==4)
       return;
       
    var checkState = tree.isItemChecked(itemId); 
    if('0' == checkState){
	    //判断是否选择了其他分类的选项
	    var userData = tree.getUserData(itemId,"tagtype");
	    if("" == tagtype){
	    	tagtype = userData;
	    }else{
	    	if(tagtype != userData){
	    	   alert("检索主题分类共分为四个主题：病名、方剂、证候、中药，同时只能选择一个主题分类！");
	    	   tree.clearSelection(itemId);
	    	   return;
	    	}
	    }
    	tree.setSubChecked(itemId,1) ;
    }
    if('1' == checkState){
    	tree.setSubChecked(itemId,0) ;
    	var allselects = getAllselectedId();
    	if("" == allselects){
    	     tagtype = "";
    	}
    	
    }
    //提交检索
    submitSearch();
};
function tondblclick(itemId) {
     
};
function toncheck(itemId) {
    if(itemId == 10000)
       return;
    var checkState = tree.isItemChecked(itemId); 
    tree.setSubChecked(itemId,checkState) ;
   //var nodelist = tree.getAllSubItems(itemId);
   //for(var i=0;i<nodelist.length;i++){
   	//	var subnode = tree.getAllSubItems(itemId);
   		
  // }
  	var allselects = getAllselectedId();
    	if("" == allselects){
    	     tagtype = "";
    	}
    //提交检索
    submitSearch();
};
function tonopen(id, mode) {
    return confirm("Do you want to " + (mode > 0 ? "close": "open") + " node " + tree.getItemText(id) + "?");
}; 

function doOnLoad() {
   //tree
tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "97%", 0);
tree.enableTreeLines(true);
tree.enableCheckBoxes(true);
//tree.setSkin('dhx_skyblue');
tree.setImagePath("<%=basePath %>thirtpart/dhtmlx25/imgs/csh_winstyle/");
tree.enableDragAndDrop(0);
tree.enableTreeLines(true);
//tree.setImageArrays("plus", "", "", "", "plus.gif");
//tree.setImageArrays("minus", "", "", "", "minus.gif");
//tree.setStdImages("book.gif", "books_open.gif", "books_close.gif");
//tree.setImageArrays("plus", "", "", "", "", "plus.gif");
//tree.setImageArrays("minus", "", "", "", "", "minus.gif");
//tree.setStdImages("book.gif", "folderOpen.gif", "folderClosed.gif");
 
//tree.setOnOpenHandler(tonopen);
//tree.attachEvent("onOpenEnd", function(nodeId, event) {
//    doLog("An id of open item is " + nodeId);
//});
tree.setOnClickHandler(tonclick);
tree.setOnCheckHandler(toncheck);
tree.attachEvent("onBeforeCheck", function(id,state){
	var userData = tree.getUserData(id,"tagtype"); 
    if("0" == state ){
	    if("" == tagtype){
	    	tagtype = userData;
	    	return true;
	    }else{
	    	if(tagtype != userData){
	    	   alert("检索主题分类共分为四个主题：病名、方剂、证候、中药，同时只能选择一个主题分类！"); 
	    	   return false;
	    	}else{
	    	   return true;
	    	}
	    } 
    } else{
    	return true;
    }
});

//tree.setOnDblClickHandler(tondblclick);

tree.preventIECaching(true);
//tree.enableSmartXMLParsing(true);//false to disable 
tree.enableDistributedParsing(true,20,50);
//tree.enableSmartXMLParsing(true); 

tree.setXMLAutoLoading("<%=basePath %>catagory/loadnode.do");
// tree.loadXML("<%=basePath %>search/subjecttree.do");
tree.loadXML("<%=basePath %>catagory/maintree.do");	
	
}
doOnLoad(); 
var divH = window.screen.availHeight*0.73;
document.getElementById("treeboxbox_tree").style.height = divH; 
//alert(document.getElementById("treeboxbox_tree").style.height);
//alert(window.screen.availHeight);
//tree.showItemCheckbox(1, false);
 function resetAll(){
 	clearAllSelectedItem();
 }

	</script>
